    //datagrid�������ϲ�ָ����Ԫ��
function mergeCells(gridId, data, arr) {

    var dg = $('#' + gridId);    //Ҫ�ϲ���datagrid�еı��id  
    var rowCount = dg.datagrid("getRows").length;
    var cellName;
    var span;
    var perValue = "";
    var curValue = "";
    var perCondition = "";
    var curCondition = "";
    var flag = true;
    var condiName = "";
    var length = arr.length - 1;
    for (var i = length; i >= 0; i--) {
        cellName = arr[i].mergeFiled;
        condiName = arr[i].premiseFiled;
        if (!condiName || condiName === "") {
            flag = false;
        }
        perValue = "";
        perCondition = "";
        span = 1;
        for (var row = 0; row <= rowCount; row++) {
            if (row === rowCount) {
                curValue = "";
                curCondition = "";
            } else {
                curValue = dg.datagrid("getRows")[row][cellName];
                if (!flag) {
                    curCondition = dg.datagrid("getRows")[row][condiName];
                }
            }
            if (perValue === curValue && (flag || perCondition === curCondition)) {
                span += 1;
            } else {
                var index = row - span;
                dg.datagrid('mergeCells', {
                    index: index,
                    field: cellName,
                    rowspan: span,
                    colspan: null
                });
                span = 1;
                perValue = curValue;
                if (!flag) {
                    perCondition = curCondition;
                }
            }
        }
    }
}